updating oE allocate_code

Allocating and Writing to memory:

allocate_code

include machine.e 
namespace machine 
public function allocate_code(object data, memconst :valid_wordsize wordsize = 1) 

allocates and copies data into executable memory.

Parameters:
  1. a_sequence_of_machine_code : is the machine code to be put into memory to be later called with call
  2. the word length : of the said code. You can specify your code as 1-byte, 2-byte or 4-byte chunks if you wish. If your machine code is byte code specify 1. The default is 1.
Returns:

An address, The function returns the address in memory of the code, that can be safely executed whether DEP is enabled or not or 0 if it fails. On the other hand, if you try to execute a code address returned by allocate with DEP enabled the program will receive a machine exception.

Comments:

Use this for the machine code you want to run in memory. The copying is done for you and when the routine returns the memory may not be readable or writeable but it is guaranteed to be executable. If you want to also write to this memory after the machine code has been copied you should use allocate_protect instead and you should read about having memory executable and writeable at the same time is a bad idea. You mustn't use free on memory returned from this function. You may instead use free_code but since you will probably need the code throughout the life of your program's process this normally is not necessary. If you want to put only data in the memory to be read and written use allocate.

See Also:

Executable Memory, allocate, free_code, allocate_protect

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu